package com.cxs.service.sys.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cxs.dao.sys.UserDAO;
import com.cxs.model.PageData;
import com.cxs.model.PageInfo;
import com.cxs.model.sys.Sys_User;
import com.cxs.service.sys.UserService;
import com.cxs.util.KEYUtil;
@Service
public class UserServiceImpl implements UserService{
	@Resource
	private UserDAO userDAO;
	
	public PageData<Sys_User> pageUser(Map<String, Object> paramMap) {
		Object pageSize = paramMap.get(KEYUtil.PAGESIZE);
		Object pageIndex = paramMap.get(KEYUtil.PAGEINDEX);

		Integer _pageSize = (Integer) pageSize;
		Integer _pageIndex = (Integer) pageIndex;

		Integer totalCount = userDAO.countUser(paramMap);
		PageInfo pageInfo = new PageInfo(totalCount, _pageSize, _pageIndex);
		paramMap.put(KEYUtil.START, (_pageIndex - 1) * _pageSize);
		paramMap.put(KEYUtil.END, _pageSize);

		List<Sys_User> list = userDAO.listUser(paramMap);
		PageData<Sys_User> pageData = new PageData<Sys_User>();
		pageData.setPageInfo(pageInfo);
		pageData.setList(list);
		return pageData;
	}
	
}
